// DeleteVerses.cpp : implementation file
//

#include "stdafx.h"
#include "SwordBible.h"
#include "DeleteVerses.h"


// CDeleteVerses dialog

IMPLEMENT_DYNAMIC(CDeleteVerses, CDialog)

CDeleteVerses::CDeleteVerses(CWnd* pParent /*=NULL*/)
	: CDialog(CDeleteVerses::IDD, pParent)
{
	arr.RemoveAll();

}

CDeleteVerses::~CDeleteVerses()
{
}

void CDeleteVerses::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	DDX_Control(pDX, IDC_TREE_VERSES, treeCtrl);
}


BEGIN_MESSAGE_MAP(CDeleteVerses, CDialog)
	ON_BN_CLICKED(IDOK, &CDeleteVerses::OnOk)
	ON_BN_CLICKED(ID_DELETEVERSE, &CDeleteVerses::OnDelete)
END_MESSAGE_MAP()


// CDeleteVerses message handlers
BOOL CDeleteVerses::OnInitDialog()
{
	CDialog::OnInitDialog();

	
	

   HICON icon_file = ::AfxGetApp()->LoadIcon(IDI_ICON_FILE);
	

	m_image.Create(16,16, ILC_COLORDDB ,0,1);
	m_image.SetBkColor(RGB(255,255,255));
	m_image.Add(icon_file);


	treeCtrl.SetImageList(&m_image, TVSIL_NORMAL );

	// add background effect
	treeCtrl.SetBkColor( RGB(245,255,255));

	treeCtrl.ModifyStyle(NULL, treeCtrl.GetStyle() |TVS_HASLINES |TVS_LINESATROOT|TVS_SHOWSELALWAYS|
			TVS_DISABLEDRAGDROP );

	// add strings to the tree control
	int count = arr.GetCount();
	FirstItem = NULL;

	if(count) FirstItem = treeCtrl.InsertItem(arr.GetAt(0));


	for(int i = 1; i < count; i++)		
		treeCtrl.InsertItem(arr.GetAt(i));


	


	return TRUE;
}

// wrapper function to add an item to the tree control
void CDeleteVerses::InsertItem(CString item)
{

	arr.Add(item);
	
}



void CDeleteVerses::OnOk()
{
	// TODO: Add your control notification handler code here
	HTREEITEM tItem = treeCtrl.GetRootItem();
	modVerseList = "";
	
	
	while(tItem != NULL)
	{
	
	modVerseList += treeCtrl.GetItemText(tItem) + ", ";
	tItem = treeCtrl.GetNextSiblingItem(tItem);
	}


	OnOK();
}

void CDeleteVerses::OnDelete()
{
	HTREEITEM tItem = treeCtrl.GetSelectedItem();
	if(tItem) treeCtrl.DeleteItem(tItem);
}
